package Day08_17;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Test_FileCopy01 {
    public static void main(String[] args) {
        FileInputStream fis = null;
        FileOutputStream fos = null;

        try {
            fis = new FileInputStream("C:\\Users\\27142\\Pictures\\abdd75aeb17040248a31431c55aae001.jpg");
            fos = new FileOutputStream("D:\\File\\A\\B\\C\\D\\abdd75aeb17040248a31431c55aae001.jpg");
            byte[] bytes = new byte[1024*1024];
            int readCount =0;

            while((readCount = fis.read(bytes))!= -1){
                fos.write(bytes,0,readCount);
            }
            fos.flush();

        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            if(fis!=null){
                try {
                    fis.close();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            if(fos!=null){
                try {
                    fos.close();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }

    }
}
